package fonkin.com.wifisignapp.fragment;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.ycl.tabview.library.TabView;
import com.ycl.tabview.library.TabViewChild;

import java.util.ArrayList;
import java.util.List;

import fonkin.com.wifisignapp.R;


public class MainFragment extends FragmentActivity {
    TabView tabView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_fragment);
        //全屏



        tabView= (TabView) findViewById(R.id.tabView);
        //start add data
        List<TabViewChild> tabViewChildList=new ArrayList<>();
        TabViewChild tabViewChild01=new TabViewChild(R.drawable.home_press,R.drawable.home,"首页", HomeFragment.newInstance("首页"));
        TabViewChild tabViewChild02=new TabViewChild(R.drawable.proceeding_press,R.drawable.proceeding,"通讯录",  ProceedingFragment.newInstance("通讯录"));
        TabViewChild tabViewChild03=new TabViewChild(R.drawable.sign_press,R.drawable.sign,"签到",  SignFragment.newInstance("签到"));
        TabViewChild tabViewChild04=new TabViewChild(R.drawable.about_me_press,R.drawable.about_me,"我的",  AboutMeFragment.newInstance("我的"));
        tabViewChildList.add(tabViewChild01);
        tabViewChildList.add(tabViewChild02);
        tabViewChildList.add(tabViewChild03);
        tabViewChildList.add(tabViewChild04);
        //end add data
        //start custom style
        tabView.setTextViewSelectedColor(Color.rgb(115,110,176));
        tabView.setTextViewUnSelectedColor(Color.rgb(191,191,191));
        //tabView.setTabViewBackgroundColor(Color.rgb());
        tabView.setTabViewHeight(dip2px(52));
        tabView.setImageViewTextViewMargin(2);
        tabView.setTextViewSize(12);
        tabView.setImageViewWidth(dip2px(28));
        tabView.setImageViewHeight(dip2px(28));
        tabView.setTabViewGravity(Gravity.TOP);

        tabView.setTabViewDefaultPosition(0);
        //end of custom
        tabView.setTabViewChild(tabViewChildList,getSupportFragmentManager());
        tabView.setOnTabChildClickListener(new TabView.OnTabChildClickListener() {
            @Override
            public void onTabChildClick(int  position, ImageView currentImageIcon, TextView currentTextView) {

            }
        });
    }

    public  int dip2px(float dpValue)
    {
        final float scale = getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }

    private void initState() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            //透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //透明导航栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
    }
}
